window.ace_ajax_content_options = {
	// 自定义配置
	'urlPath'  : "/module/",
	'urlPrefix': $.url.segment(0),
	'urlSuffix': ".html",
	// asc基本配置
	'close_active': true,
	'close_mobile_menu': '#sidebar',
	'close_dropdowns': true,
	'default_url': 'page/Index/index',//default hash
	'content_url': function(hash) {
		var options = window.ace_ajax_content_options;
		//***NOTE***
		//this is for Ace demo only, you should change it to return a valid URL
		//please refer to documentation for more info

		if( !hash.match(/^page\//) ) return false;
		var path = document.location.pathname;
		console.log(path);console.log(options.urlPrefix);
		var reg = new RegExp( "(\/" + options.urlPrefix + "\/)(index\.html)?" );
		//for example in Ace HTML demo version we convert /ajax/index.html#page/gallery to > /ajax/content/gallery.html and load it
		if( path.match(reg) ) {
			path = path.replace(reg, '/' + options.urlPrefix + options.urlPath + hash.replace(/^page\//, '')) ;
			path = path.indexOf('?') != -1 ? path.replace( /\?/, options.urlSuffix + '?' ) : path + options.urlSuffix;
			return path;
		}
		//for example in Ace PHP demo version we convert "ajax.php#page/dashboard" to "ajax.php?page=dashboard" and load it
		return path + "?" + hash.replace(/\//, "=");
	}
}

$(function () {
	// 配置信息
	app.init({
		contextPath : $.url.segment(0), //'gitOpen/aceAdmin1.4'
		titleName  : "Admin",
		titleIcon  : '<i class="fa fa-leaf"></i>',
		titleClass : "navbar-brand",
		userIcon   : '<small>Welcome,</small>',
		userClass  : 'user-info',
		userCookie : "user_userName",
		logoutName : 'Logout',
		logoutClass: 'user-menu',
		logoutIcon : '<i class="ace-icon fa fa-power-off"></i>',
		logoutEvent: 'logout()',
		logoutUrl  : '',
		// logoutUrl  : '/' + $.url.segment(0) + '/mvc/logout.do',
		loginUrl   : ''
		//loginUrl   : '/' + $.url.segment(0) + '/mvc/index.do'
	});
	// 显示导航
	$(".nav-list").menu({
		ajaxOption:{
			url: "/" + app.contextPath + "/resources/assets/data/menu.json"
			//url: "/" + app.contextPath + "/assets/data/menu.json"
			//url:"/" + app.contextPath+"/rest/permission/service/userMenu/getMenuTreeByParentAndUser/?userCode=" + user.userName + "&parentMenuCode="+ump.treeRoot
		},
		menuElement:{
			parentTemplate:'<li class="" id="{0}">' + 
                        '<a href="#" class="dropdown-toggle">' + 
                            '<i class="menu-icon fa {1}"></i>' + 
                            '<span class="menu-text"> {2} {4}</span>' + 
                            '<b class="arrow fa fa-angle-down"></b>' + 
                        '</a>',
			menuTemplate :'<li class="" id="{0}">' + 
                        '<a data-url="page/{3}" href="#page/{3}">' + 
                            '<i class="menu-icon fa {1}"></i>' + 
                            '<span class="menu-text"> {2} {4}</span>' + 
                        '</a>' + 
                        '<b class="arrow"></b>' + 
                    '</li>'
        }
	}).data("menu").load();
});


